<?php

$deId = $_GET['pid'] > 0 ? $_GET['pid'] : $_POST['pid'];

if ($deId < 1 || $deId == '') {

    header('Location: dienst_list.php');
    exit;
}
include_once('controller/includes/db_access.php');

if ((isset($_POST['action']) ? $_POST['action'] : (isset($_GET['action']) ? $_GET['action'] : '')) == 'multiple') {



    $q_DeleteDienst = new Query;
    $q_DeleteDienst
            ->delete_from('`diensten`')
        
           
            ->where_equal_to(
                    array(
                        '`diensten`.`dienst_id`' => $deId
                    )
            )
            ->limit(1);

    $resultDienst = $q_DeleteDienst->run();
    $dienst_id = $q_DeleteDienst->get_deleted();
    if (!($resultDienst && $dienst_id > 0)){
        
        $Error = 'No dienst found.' . "\n";
        
    } else 
        {

           header('Location: dienst_list.php');  
           
        }
}


if (isset($_GET['pid'])) {

    $id = $_GET['pid'];

$query="SELECT * 
FROM diensten
WHERE dienst_id =".$id;
$result=mysql_query($query);
$rows_dienst=mysql_fetch_array($result); 


}
?>


<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<!--[if lt IE 9]>
<script
src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link rel="stylesheet" href="styles/style.css" type="text/css" />
<!--[if lte IE 7]>
<link rel="stylesheet" href="style_ie.css" />
<![endif]-->
<title>dbme!!!!</title>
</head>
<body>
<div id="bloc_page">
<header>
 <a href="#"><img src="../images/dBmelogo.png" alt="referentie" alt="dbme!" /></a>
</header>  
 <nav>
    <?php include_once('header.php'); ?>
</nav>
 <section>
  <aside>
  <!--right side baar -->  
  </aside>
     
  <article>  
<table border="0" cellspacing="5" cellpadding="5">

        <tbody>
        <form name="form1" method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>" enctype="multipart/form-data">
        <input type="hidden" name="action" value="multiple" />
        <input type="hidden" name="pid" value="<?php echo $_GET['pid']; ?>" />
            <tr>
                <td colspan="2"><h1>Dienst add</h1><br/><br/>
                <?php if(isset($Error)) echo $Error; ?></td>
            </tr>
            <tr>
                <td valign="top">Dienst naam:
                </td>
                <td valign="top"> <?php echo $rows_dienst->naam; ?>
                   
                </td>
            </tr>
            <tr>
                <td valign="top">Beschrijving:<br />
                
                </td>
                <td valign="top"> <?php echo $rows_dienst->descr; ?>
                   
                </td>
            </tr>
            <tr>
               <?php if($rows_dienst->eenxdienst == 'Y') 
                   {
                    echo "Deze dienst 1 x per verhuur periode berekenen (bijv op/afbouw, alleen eerste en laaste dag)";
                   }
                if( $rows_dienst->eenxdienst == 'N')  { 
                     echo "Deze dienst elke dag van de verhuur periode berekenen (bijv technicus)"; 
                    }
                   ?>

                </td>
            </tr>
             <tr>
                 <td valign="top">Prijs&nbsp;(incl. BTW):
                </td>
                <td valign="top"><?php echo $rows_dienst->prijs; ?>
                   
                </td>
            </tr>
             <tr>
                <td valign="top" colspan="2"> 
                    
                    <?php if($rows_dienst->altijd_toepassen == 'Y') 
                   {
                        
                     echo " Deze dienst is naar keuze van klant wel/niet af te nemen.";
                   
                   }
               else{ 
                     
                      echo "Deze dienst wordt standaard toegepast op elke offerte."; 
                   
                   }
                   ?>
               
           
                </td>
            </tr>
                 
             <tr>
                 
                <td valign="top"  colspan="2">Hoe vaak per dag kunt u deze dienst maximaal leveren? <?php echo $rows_dienst->aantal_per_dag; ?>
                </td>
       
             
            </tr>
            <tr>
                <td valign="top">Aktief 
                                                                                    
             </td>
            <td valign="top">
               <?php echo $rows_dienst->aktief == 'Y' ? 'Ja' :' Nee'; ?>                                                        
             </td>
            </tr>
            <tr>
                <td></td>
                <td><input type="submit" value="delete" name="save" />
                  </td>
            </tr>
          </form></tbody>
</table>
          </article>
 
    <aside>
  <!--right side baar -->
       
        
   </aside>
</section>
 
 <footer>  
<p>Lorem ipsum dolor sit amet...</p>
<p>Vivamus sed libero nec mauris pulvinar facilisis ut non sem...</p>
<p>Phasellus ligula massa, congue ac vulputate non, dignissim at augue...</p>
</footer>
</div>
</body>
</html>